package com.qfedu.proxy;

import com.qfedu.dao.GenaralDao;

/**
 * @author:zhengyilong
 * @email:1797344574@qq.com
 * @phone:13479394730
 * @desc:
 * @DateTime:2022/5/4 11:23
 **/
public class MyStaticProxy {

    private GenaralDao genaralDao;
    public MyStaticProxy(GenaralDao genaralDao) {
        this.genaralDao = genaralDao;
    }

    public void insert(){
        begin();
        genaralDao.insert();
        commit();
    }

    public void delete(){
        begin();
        genaralDao.delete();
        commit();
    }

    public void update(){
        begin();
        genaralDao.update();
        commit();
    }

    long time1;
    long time2;
    public void begin(){
        time1 = System.currentTimeMillis();
        System.out.println("---开启事务");
    }

    public void commit(){
        System.out.println("---提交事务");
        time2 = System.currentTimeMillis();
        System.out.println(genaralDao.getClass()+"执行时间为："+(time2-time1));
    }

}

